﻿/*
Copyright (C) 2009  Tomasz Chrzanowski

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>
*/

using System;
using System.Collections.Generic;
using System.Text;

namespace Com.TomCdc.ChangeDataCapture
{
    /// <summary>
    /// Represents a collection of case insensitive objects that can be individually accessed by index.
    /// </summary>
    public class CaseInsensitiveList : List<string>
    {
        public CaseInsensitiveList()
        {
        }

        public CaseInsensitiveList(string[] a)
        {
            base.AddRange(a);
        }


        /// <summary>
        /// Determines whether the collection contains a specific value. Performs case insesitive search, 
        /// using <see cref="System.StringComparison.OrdinalIgnoreCase"/> comparer.
        /// </summary>
        /// <param name="item">The object to locate in the collection (case insensitive search).</param>
        /// <returns></returns>
        public new bool Contains(string item)
        {
            return this.Exists(delegate(string s)
                        {
                            return s.Equals(item, StringComparison.OrdinalIgnoreCase);
                        }
                    );
        }
    }
}
